package com.tsyun.view_project;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.tsyun.view_project.list.ListViewActivity;
import com.tsyun.view_project.recycler.RecyclerActivity;
import com.tsyun.view_project.refresh.RefreshActivity;
import com.tsyun.view_project.snackbar.SnackbarActivity;
import com.tsyun.view_project.text.SpannableActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btnRefresh = findViewById(R.id.btn_refresh);
        btnRefresh.setOnClickListener(this);
        findViewById(R.id.btn_spannable).setOnClickListener(this);
        findViewById(R.id.btn_text).setOnClickListener(this);
        findViewById(R.id.other_view).setOnClickListener(this);
        findViewById(R.id.btn_snackbar).setOnClickListener(this);
        findViewById(R.id.btn_recycler).setOnClickListener(this);
        findViewById(R.id.btn_webView).setOnClickListener(this);
        findViewById(R.id.btn_tencent_webView).setOnClickListener(this);
        findViewById(R.id.btn_dialog).setOnClickListener(this);
        findViewById(R.id.btn_listview).setOnClickListener(this);

//        LinearLayout linearLayout = new LinearLayout(this);
//        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
//        linearLayout.setLayoutParams(params);
//        try {
//            Thread.sleep(10000);
//            TextView tv = findViewById(R.id.tv_demo);
//            tv.setOnClickListener((v) -> {
////                    Toast.makeText(MainActivity.this,"点击了我",Toast.LENGTH_SHORT).show();
//                        Intent intent = new Intent();
//                        intent.setClass(this, TableActivity.class);
//                        startActivity(intent);
//                    }
//            );
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.other_view:
                startActivity(new Intent(this, OtherViewActivity.class));
                break;
            case R.id.btn_refresh:
                //跳转到RefreshActivity界面
                startActivity(new Intent(this, RefreshActivity.class));
                break;
            case R.id.btn_spannable:
                //SpannableActivity
                startActivity(new Intent(this, SpannableActivity.class));
                break;
            case R.id.btn_text:
                startActivity(new Intent(this, TextViewActivity.class));
                break;
            case R.id.btn_recycler:
                startActivity(new Intent(this, RecyclerActivity.class));
                break;
            case R.id.btn_snackbar:
                startActivity(new Intent(this, SnackbarActivity.class));
                break;
            case R.id.btn_webView:
                startActivity(new Intent(this, WebViewActivity.class));
                break;
            case R.id.btn_tencent_webView:
                startActivity(new Intent(this, TencentWebViewActivity.class));
                break;
            case R.id.btn_dialog:
                startActivity(new Intent(this, DialogActivity.class));
                break;
            case R.id.btn_listview:
                startActivity(new Intent(this, ListViewActivity.class));
                break;

        }
    }
}